package cn.com.generaldata.os.util;

import java.io.IOException;

public class XmlWSTEncrypt {
	static {
		// System.loadLibrary("libencrypt_f");
		System.load("D:\\myprogram\\JavaProgram\\OceanService_Lan\\web\\WEB-INF\\classes\\libencrypt_f.dll");
	}

	public native static String getString();

	public native static void setString(String vString);

	public static String outString;

	public static void main(String[] args) {
		// XmlWSTEncrypt wste = new XmlWSTEncrypt();

		// String content = "shanglongkeji";
		// wste.setInString(args[0]);
		System.out.println("XmlWSTEncrypt调用：" + args[0]);
		XmlWSTEncrypt.setString(args[0]);
		XmlWSTEncrypt.setOutString(XmlWSTEncrypt.getString());
		System.out.println(XmlWSTEncrypt.getOutString());
		// XMLUtil.setEncryptString(wste.getOutString());

		String command = "msg * " + XmlWSTEncrypt.getOutString();
		Runtime r = Runtime.getRuntime();
		try {
			@SuppressWarnings("unused")
			Process p = r.exec(command);
		} catch (IOException e) {
			// e.printStackTrace();
		}
	}

	public static String outEncrypt(String content) {
		System.out.println("outEncrypt调用：" + content);
		String command = "java cn.com.generaldata.os.util.XmlWSTEncrypt " + content;
		Runtime r = Runtime.getRuntime();
		try {
			@SuppressWarnings("unused")
			Process p = r.exec(command);
			return "卫士通加密运行结束...";
		} catch (IOException e) {
			return "卫士通加密失败！！！";
			// e.printStackTrace();
		}
	}

	public static String getOutString() {
		return outString;
	}

	public static void setOutString(String outString) {
		XmlWSTEncrypt.outString = outString;
	}
}
